clc
clear

M1 = generate_mseq([1, 0, 1, 1]);
M2 = circshift(M1, [0 1]); % сдвинуть по строке
M3 = circshift(M2, [0 1]);

M1(M1 == 0) = -1;
M2(M2 == 0) = -1;
M3(M3 == 0) = -1;

res = -M1 + M2 + M3;

% детектор 1
if sum(res .* M1) < 0.0
    fprintf('\nuser 1: sends 0.\n')
else
    fprintf('\nuser 1: sends 1.\n')
end

% детектор 2
if sum(res .* M2) < 0.0
    fprintf('user 2: sends 0.\n')
else
    fprintf('user 2: sends 1.\n')
end

% детектор 3
if sum(res .* M3) < 0.0
    fprintf('user 3: sends 0.\n')
else
    fprintf('user 3: sends 1.\n')
end
